import pandas as pd

import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.metrics import PrecisionRecallDisplay

mpl.rcParams['lines.linewidth'] = 2

font = {'size': 13}

mpl.rc('font', **font)

base = pd.read_csv("data.csv")
base.rename( columns = {"Input.item1_title": "amicus", "Input.item2_title":"bonica"}, inplace = True)

#chatGPT scores
t1 = pd.read_csv("experiment_1_temp1.0.csv")[["amicus", "bonica", "chatGPT_score"]]
t1.rename( columns = {"chatGPT_score": "chatGPT_temp1.0_score"}, inplace = True)
t2 = pd.read_csv("experiment_1_temp0.2.csv")[["amicus", "bonica", "chatGPT_score"]]
t2.rename( columns = {"chatGPT_score": "chatGPT_temp0。2_score"}, inplace = True)


df = pd.merge(base, t1, left_on=["amicus", "bonica"], right_on=["amicus","bonica"])
df = pd.merge(df, t2, left_on=["amicus", "bonica"], right_on=["amicus","bonica"])

fig, ax = plt.subplots(figsize=(12, 8), nrows = 2, ncols = 4, sharex = True, sharey = True)

fig.tight_layout()

print(ax)
print(len(ax))
print(ax[0])

print(df.columns)

mapper = {"hitl_score": "HITL", "basic_score": "Base Model", "cosine": "Cosine", "jaccard": "Jaccard", "overlap": "n-Gram Overlap", "jw": "Jaro-Winkler", "chatGPT_temp1.0_score": "chatGPT_temp1.0", "chatGPT_temp0.2_score": "chatGPT_temp0.2"}

df.rename(columns=mapper, inplace = True)

print(df.columns)

for i, score in enumerate(list(mapper.values())):
	display = PrecisionRecallDisplay.from_predictions(df["label.y"], df[score], name=score, plot_chance_level=False)
	row = i // 4
	col = i % 4
	display.plot(ax = ax[row][col], color = "black")

plt.show()
